﻿using MediatR;
using SqlSugar;
using Warehouse.ErrorCord;
using Warehouse.Read.Api.Actions.Command.WarehouseCategory;

namespace Warehouse.Read.Api.Actions.CommandHandel.WarehouseCategory
{
    public class GetTypeCommandhandle : IRequestHandler<GetTypeCommand, APIResult<List<Warehouse.Domain.WarehouseCategory>>>
    {
        private readonly ISqlSugarClient db;

        public GetTypeCommandhandle(ISqlSugarClient db)
        {
            this.db = db;
        }

        public Task<APIResult<List<Warehouse.Domain.WarehouseCategory>>> Handle(GetTypeCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<Warehouse.Domain.WarehouseCategory>> result = new APIResult<List<Warehouse.Domain.WarehouseCategory>>();
            var list=db.Queryable<Warehouse.Domain.WarehouseCategory>().ToList();
            result.Code = APIEnum.Success;
            result.Msg = "查询成功";
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
